/*   1:    */ package com.example.administrator.myjdlc.net;
/*   2:    */ 
/*   3:    */

import android.annotation.SuppressLint;

import com.example.administrator.myjdlc.utils.CharacterParser;
import com.example.administrator.myjdlc.utils.CommonUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */ 
/*  15:    */ public class SignUtil
/*  16:    */ {
/*  17:    */   @SuppressLint({"DefaultLocale"})
/*  18:    */   public static String createSign(Map<String, String> params)
/*  19:    */   {
/*  20: 27 */     List<String> list = new ArrayList();
/*  21: 28 */     String result = "";
/*  22: 29 */     if ((params != null) && (!params.isEmpty()))
/*  23:    */     {
/*  24: 31 */       Iterator localIterator1 = params.entrySet().iterator();
/*  25: 30 */       while (localIterator1.hasNext())
/*  26:    */       {
/*  27: 31 */         Entry<String, String> entry = (Entry)localIterator1.next();
/*  28: 33 */         if ((!((String)entry.getKey()).equals("password")) && (!((String)entry.getKey()).equals("account_info")) && 
/*  29: 34 */           (!((String)entry.getKey()).equals("new_pwd")) && (!((String)entry.getKey()).equals("image")) && 
/*  30: 35 */           (!((String)entry.getKey()).equals("Comment")) && (!((String)entry.getKey()).equals("Item1")) && 
/*  31: 36 */           (!((String)entry.getKey()).equals("Item2")) && (!((String)entry.getKey()).equals("Item3")) && 
/*  32: 37 */           (!((String)entry.getKey()).equals("Item4")) && 
/*  33: 38 */           (entry.getValue() != null) && 
/*  34: 39 */           (!((String)entry.getValue()).toString().equals(""))) {
/*  35: 40 */           list.add((String)entry.getKey());
/*  36:    */         }
/*  37:    */       }
/*  38: 47 */       List<String> newList = listSort(list);
/*  39: 48 */       for (String str : newList) {
/*  40: 49 */         if (result.equals("")) {
/*  41: 50 */           result = 
/*  42: 51 */             str + "=" + (String)params.get(str);
/*  43:    */         } else {
/*  44: 53 */           result = 
/*  45: 54 */             result + "&" + str + "=" + (String)params.get(str);
/*  46:    */         }
/*  47:    */       }
/*  48: 57 */       result = result + "&appsecret=" + "afff9708359346c6a04df04d800ff8e1";
/*  49: 58 */       result = CommonUtils.md5(result).toUpperCase();
/*  50:    */     }
/*  51: 60 */     return result;
/*  52:    */   }
/*  53:    */   
/*  54:    */   public static List<String> listSort(List<String> list)
/*  55:    */   {
/*  56: 70 */     String[] array = (String[])list.toArray(new String[list.size()]);
/*  57: 71 */     for (int i = 0; i < array.length - 1; i++) {
/*  58: 72 */       for (int j = i + 1; j < array.length; j++) {
/*  59: 73 */         if (singleSort(array[i], array[j]) == 1)
/*  60:    */         {
/*  61: 74 */           String temp = array[i];
/*  62: 75 */           array[i] = array[j];
/*  63: 76 */           array[j] = temp;
/*  64:    */         }
/*  65:    */       }
/*  66:    */     }
/*  67: 80 */     return Arrays.asList(array);
/*  68:    */   }
/*  69:    */   
/*  70:    */   private static int chineseCompare(String one, String two, int i)
/*  71:    */   {
/*  72:    */
/*  73:    */     String substringleft;
/*  74:    */     String substringright;
/*  75: 94 */     if (i > 0)
/*  76:    */     {
/*  77: 95 */       substringleft = one.substring(i - 1, i);
/*  78: 96 */       substringright = two.substring(i - 1, i);
/*  79:    */     }
/*  80:    */     else
/*  81:    */     {
/*  82: 98 */       substringleft = one.substring(0, i);
/*  83: 99 */       substringright = two.substring(0, i);
/*  84:    */     }
/*  85:103 */     int subLeft = stringToAscii(CharacterParser.convert(substringleft)
/*  86:104 */       .substring(0, 1))[0];
/*  87:105 */     int subRight = stringToAscii(CharacterParser.convert(substringright)
/*  88:106 */       .substring(0, 1))[0];
/*  89:107 */     System.out.println(CharacterParser.convert(substringleft).substring(0, 
/*  90:108 */       1));
/*  91:109 */     return intCompare(subLeft, subRight);
/*  92:    */   }
/*  93:    */   
/*  94:    */   public static int singleSort(String one, String two)
/*  95:    */   {
/*  96:121 */     int[] left = stringToAscii(one);
/*  97:122 */     int[] right = stringToAscii(two);
/*  98:123 */     int size = left.length < right.length ? left.length : right.length;
/*  99:124 */     for (int i = 0; i < size; i++) {
/* 100:126 */       if ((left[i] > 10000) && (right[i] > 10000) && (left[i] != right[i]))
/* 101:    */       {
/* 102:127 */         if (chineseCompare(one, two, i) != 0) {
/* 103:128 */           return chineseCompare(one, two, i);
/* 104:    */         }
/* 105:    */       }
/* 106:131 */       else if (intCompare(left[i], right[i]) != 0) {
/* 107:132 */         return intCompare(left[i], right[i]);
/* 108:    */       }
/* 109:    */     }
/* 110:136 */     return intCompare(left.length, right.length);
/* 111:    */   }
/* 112:    */   
/* 113:    */   private static int intCompare(int subLeft, int subRight)
/* 114:    */   {
/* 115:146 */     if (subLeft > subRight) {
/* 116:147 */       return 1;
/* 117:    */     }
/* 118:148 */     if (subLeft < subRight) {
/* 119:149 */       return -1;
/* 120:    */     }
/* 121:151 */     return 0;
/* 122:    */   }
/* 123:    */   
/* 124:    */   public static int[] stringToAscii(String value)
/* 125:    */   {
/* 126:161 */     char[] chars = value.toCharArray();
/* 127:162 */     int j = chars.length;
/* 128:163 */     int[] array = new int[j];
/* 129:164 */     for (int i = 0; i < chars.length; i++) {
/* 130:165 */       array[i] = chars[i];
/* 131:    */     }
/* 132:167 */     return array;
/* 133:    */   }
/* 134:    */ }



/* Location:           C:\Users\Administrator\Desktop\BaseUtils.jar

 * Qualified Name:     com.jzkj.manage.net.SignUtil

 * JD-Core Version:    0.7.0.1

 */